import React, { useState } from 'react'

function Home() {
    // useState  定义基础数据类型
    let [num, setNum] = useState(888)
    let [obj, setObj] = useState({
        name: "张三",
        age: 18
    })
    return (
        <div>
            {/* Home -- { num }
            <button onClick = { () => {
                setNum(num + 1)
            } }>+++</button> */}

            <h3>
                姓名：{ obj.name }
            </h3>
            <h3>
                age：{ obj.age }
            </h3>
            <button onClick = {() => {
                let obj2 = { ...obj }
                obj2.name = "李四"
                setObj(obj2)
            }}>改变姓名</button>
        </div>
    )
}

export default Home
